﻿package com.alipay.config;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

public class AlipayConfig {
	
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	public static String app_id = "2016091400508254";
								   
	// 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC57kxAftuFJX1jCn4a/XOnFAiXY1mTblXra82AQvcd/RojrZ7WQzofdky4l9bhptV2637qt/uxMGuRATd+M0JosDSxytiwIZWEp0WEXdewcZXv6Fbgh5MoO1GC3+Vzxu4EOq9dmVge54Y2j2coz10Yd7If+ukamP+1aNfeWmnd9ZDGOvCKAFXaXTB5DzEhnYmAThxXV9QNh3ImJMt5/9j9mvBI1lgbqIlL7+c86qvSxQhFRDYjrfNMtJ2kLOMbp4A+PIxiKtuEJhb4JBpQ0gDnThokVM58u3AhCOErt+u7ZXDRitUZQ6UGZwQe39l891DrLNHWyQ+yuUOW0W5KvxXTAgMBAAECggEAP81XGzas66auvULHfUmF20qTnCd6gI33K98FWMMh+4dz5dRZUhslodA9iYaJNUvDqpgrKC5UTzxXXR32xfafDj+RBYWfD+mmXivsPfzZ2/FOS1IGJexAAilA0lE0cqNL3+Wncc4CIDDArI5PDwEBaDkCxdibDwZ7kOvWT7Xk6EYaD70mNpGVRCM4sPrvNA0zD2qK+Rzlxq5umiolgnUtOmr5XRdoNWQGtnLhEVaJaLWSzpocLHVJ1EClHHn+nNEDkfqg6wsVbKAs26TpLXVx6hs6fHvcMgheVq958SpHShzcgyg4VlXWQbl5ufK/moHnaROg5JDQhNAvKv8pNlsvcQKBgQD4uaXQM0cxn/pob2W7CfojFjSIm7Quern4S/2LWdP55CaE4FeSlzQNFSbuCTDeOl6MWC9D9OOGrJ3kjtAAMiqxD01VXbY448Q4WiXsRiBzeNb1tYJiVwGMnuvjqrizTQ6Y24kG58hxCpsm7kn5yz8fv79G3mAOVV8yyS/0JiBZGQKBgQC/XnjOG9P/J9wPvTc3SmRbmsp+GN7LvyCDpXxGwVoI1duxFbrCI4vDUgHcjDaIhLUUh3mcihdcbpyB3Ik2TBU6VbcYoKtQxa2+1kCDOwI+pwn7DsbZZ+nx6FZ4D6CzCVsa8LptHwbhnmM+98bz1v6CBpdJMfe6jZkJ23sFlUbHywKBgB25Ue+HsUJk8+/3IBkyIAqBZNXOhcHoOMFLk4lLuuFqOpA2n0CNgVLu7DAWORjVsObkwwFECszVZCkkSAc994whYASLpnM2BQUXAOEzoD0se8PxZRuLekvr0hTrGheTZeMumTmSCYo40kHcyEpp16lbqOg3OxN7cF0JXgm3ZLZBAoGBAIOR7ji2hUCOJQxlKQtIiEs61zFu4+7tDuuz4Qe8c6xTbGIJ8Ib9bV/yh/kcJXoi02Sz5/aqMnmISu41s9iy4n1i5Sl3fZFg952XLG+NKHPu4DvN4wUiHoQFGz4ccH3nVs3k6CeSB2cjQFTQgeavz/eRlH3sbsfCBo/yaFhkU2+VAoGAI1PuJ/3lkGysBodW9+Pw9XK2lFPQ6Rh6LECnGx4fh4zuakgCncf3wkMJ/KTQO3QSJuVt4dnKCDjzhphLzOn43JGr795Z/Zr3kh35abGVeSAj31aVL1YCK7D/kA0TkYAJKmTLceSsRFocz3n7Nz2m6MZ4bqYbtfVYYA5RLs6AtI0=";
	
	// 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4kn/KTn0gg+kaYOPnFTa0ya2diS3MWBoqqbePJp5CTm9cW4uoWjMfG1uhp4zHiZ+dz0Kqu5CReKj+ngsJ1/AOqGxFEsr8Gk1473i3gM5wQAWyTLuJRDwQM2Gam4woTEYuDioiz8idxGtI49PlUHmeqrjuQOZBtOaPhKiPdXGHXVlvB6Ij3zlpQ2c5sslke6+R8WsOrJ1eQ7JJ/doHgMQtpnJLpgzbNywodx2xmTOp+eQz6PPW2gfSc2ycp+KUoW5XZg2hrr4XJ15Lq9hG8jFU93wrOhcIXJTaICRkD2OGYDBbq0YrUZGot+bs6FQ8x916QvPvu+34i8NkwfLZPCUMQIDAQAB";

	// 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String notify_url = "http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String return_url = "http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";

	// 签名方式
	public static String sign_type = "RSA2";
	
	// 字符编码格式
	public static String charset = "utf-8";
	
	// 支付宝网关
	public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
	
	// 支付宝网关
	public static String log_path = "D:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /** 
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

